package com.zzyl;

import cn.hutool.http.Header;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.http.HttpHeaders;

import java.util.HashMap;
import java.util.Map;

@Slf4j
public class test {

    @Test
    public void testPost(){

        Map<String,String> params = Map.of(
                "code","0"
                ,"password","admin123"
                ,"username","admin"
                ,"uuid","f41759f431234d3294d2a46664f78d1a"
        );

        String post = HttpUtil.post("http://localhost:8080/login", JSONUtil.toJsonStr(params));
        System.out.println(JSONUtil.parse( post));

    }

    @Test
    public  void testGet(){
        HttpResponse execute = HttpUtil.createGet("http://localhost:8080/serve/project/list")
                .form("pageNum", "1")
                .form("pageSize", "6")
                .header(HttpHeaders.AUTHORIZATION, "Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImIxMzM0OWQxLTFlNWQtNDIwZC04NThkLTU0ZjgyMDk4ZWJhNyJ9.BBDLUkOXAufxqDRJZvNyQgNDx4A1_CIIZ09JLUaD1_gTj1JhB125d60NXtMHdyb5cZgWSmCgQAZHeLvHYqpJrw")
                .execute();
        if (execute.isOk()){
            System.out.println(JSONUtil.parse( execute.body()));
        }


    }


}
